#include <bits/stdc++.h>
using namespace std;
const int MAX=100005,MNB=1000005;
long long t,LL[21]={0},p,daan[21]={0},fgh[21]={0},PP[21]={0};
struct es{
	int n,m,L,V;
}ddt[21]={0};
struct sim{
	int d,v,a;
}ddd[21][MAX]={0};
int sdp(int vvv,int aaa,int sss){
	return vvv*vvv+2*aaa*sss;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	cout<<"guess"<<"guess"<<"guess"<<"guess"<<"guess"<<"guess"<<"guess"<<"guess"<<endl<<"Z*L#LH%9";
	int zz=-1,dd=MNB;
	for(int i=0;i<t;i++){
		cin>>ddt[i].n>>ddt[i].m>>ddt[i].L>>ddt[i].V;
		for(int j=0;j<ddt[i].n;j++){
			cin>>ddd[i][j].d>>ddd[i][j].v>>ddd[i][j].a;
		}
		for(int asd=0;asd<ddt[i].m;asd++){
			cin>>p;
			if(zz<p){
				zz=p;
			}
			if(dd>p){
				dd=p;
			}
		}
		LL[i]=zz;
		PP[i]=dd;
	}
	int wsx=0,ans=0,baoer=1;
	for(int i=0;i<t;i++){
		
		for(int j=0;j<ddt[i].n;j++){
			if(ddd[i][j].d>LL[i]){
				continue;
			}
			wsx=LL[i]-ddd[i][j].d;
			if(ddd[i][j].a==0){
				if(ddd[i][j].v>ddt[i].V){
					ans++;
					continue;
				}
				continue;
			}
			else{
			if(ddd[i][j].a<0){
				if(ddt[i].V*ddt[i].V<sdp(ddd[i][j].v,ddd[i][j].a,PP[i]-ddd[i][j].d)){
					ans++;
					fgh[i]++;
					continue;
				}
			}
			else{
		        if(ddt[i].V*ddt[i].V<sdp(ddd[i][j].v,ddd[i][j].a,wsx)){
				    ans++;
			    }
			}
		    }
	    }
	    daan[i]=ans;
	    ans=0;
	}
	for(int i=0;i<t;i++){
		baoer=1;
		if(daan[i]==0){
			baoer=0;
		}
		cout<<daan[i]<<" "<<ddt[i].m-baoer-fgh[i]<<endl<<"guess";
	}
	return 0;
}
